package com.sumqun.mall.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sumqun.mall.dao.AccountDao;
import com.sumqun.mall.entity.Account;
import com.sumqun.mall.service.AccountService;

@Service
public class AccountServiceImpl implements AccountService{
	
	@Autowired
	private AccountDao accountDao; 

	@Override
	public Boolean verify(String username, String password, String usertype) {
		Account user = accountDao.findLoginUser(username, password, usertype);
	    if(user!=null){
	    	return true;
	    }else{
		   return false;
	    }
	}
	
	public  Account getVerifyUser(String username, String password, String usertype) {
		Account user = accountDao.findLoginUser(username, password, usertype);
		return user;
	}

	@Override
	public Boolean verify(String uid) {
		Account user = accountDao.findAccountById(Integer.valueOf(uid));
	    if(user!=null){
	    	return true;
	    }else{
		   return false;
	    }
	}

	@Override
	public List findAllAccount(int offset, int pageSize) {		
		return accountDao.findAllAccount(offset,pageSize);
	}
	
	

	@Override
	public int findAllCount() {		 
		return accountDao.findAllCount();
	}

	@Override
	public Account findAccount(int uid) {
	  return accountDao.findAccountById(uid);
	}

	@Override
	public void register(Account account) {
		accountDao.addAccount(account);
		
	}

	@Override
	public void editAccount(Account account) {
		accountDao.editAccount(account);
		
	}

	@Override
	public void removeAccout(int uid) {
		accountDao.removeAccount(uid);
		
	}	

}
